import formJs from "./regexDetail.js"; //新增弹框配置项
import publicForm from "@/components/public/el-form.vue"; //弹框form
import TableData from "@/components/public/el-tables"; //主页面列表


import {
    getStationmachineByfMachineid, //查询-拌合站信息-详情接口
    getMixInfoById, //主页面列表详情接口 非闭合
    getStationWarnByCompanyId, // 审核流程
    addClosedForm,
    getClosedFormByParentId, //主页面列表详情接口闭合

} from "@/api/request.js";

export default {
    props: [
        "dialogVisible",
        "dialogTitle",
        "statusNum",
        "currentRow",
        "fCompanyid",
        "fCompanyname",
        "modelType",
        "isclose"
    ],
    data() {
        return {
            material_config: formJs.material_config, //材料配置项
            materialData: [], //材料用量列表
            formObjInfo: formJs.formObjInfo, //基础信息
            handleObj: formJs.handleObj, //闭合申请单
            processObj:formJs.processObj,//一级审核
            examineObj:formJs.examineObj,//二级审核
            levelThree:formJs.levelThree,//三级审核
            levelFourth:formJs.levelFourth,//四级审核

            earlyWarning: [], //提示
            level: [], //预警等级
            handNum: false, //闭合申请单
            firstNum: false, //一级审核
            secondNum: false, //二级审核
            threeLevel: false, //三级审核显示
            fourLevel: false, //四级审核显示
            handleData: {
                fCompanyid: "", // 施工标段id
                fId: "", // 申请单fid //为空判断为新增
                fParentid: "", // 对应的超标记录fid
                fWarningcontent: "", // 预警内容
                fReason: "", // 问题原因
                fHandleway: "", // 处理方式
                fHandleresult: "", // 处理结果
                fHandledate: "",
                fHandledates: this.common.day(0), // 处理日期
                fHandleusername: "", // 处理人名称
                fHandlefile: "", // 处理附件id
                fFirstcheckresult: "", // 一级审核处理结果
                fFirstcheckopinion: "", // 一级审核处理意见
                fFirstcheckusername: "", // 一级审核处理人name
                fFirstcheckdates: this.common.day(0), // 一级审核处理日期
                fSecondcheckresult: "", // 二级审核处理结果
                fSecondcheckopinion: "", // 二级审核处理意见
                fSecondcheckusername: "", // 二级审核处理人name
                fSecondcheckdates: this.common.day(0), // 二级审核处理日期
                fThirdcheckresult: "", // 三级审核处理结果
                fThirdcheckopinion: "", // 三级审核处理意见
                fThirdcheckusername: "", // 三级审核处理人name
                fThirdcheckdates: this.common.day(0), // 三级审核处理日期
                fFourthcheckresult: "", // 四级审核处理结果
                fFourthcheckopinion: "", // 四级审核处理意见
                fFourthcheckusername: "", // 四级审核处理人name
                fFourthcheckdates: this.common.day(0), // 四级审核处理日期

                aduitStatus: null, //保存状态
                userId: "", // 当前登录人id
                userName: "", // 当前登录人姓名
                recordfiles: [], // 删除文件id集合
            },
            status: null,
            checkStatus: null,
            



            activeNames: ["0", "1"],
            fileList: [],
            disabled: false, //表格中间是否禁用
            isEdit: false,

            visible: "",
            title: null,
            isLock: false,
            btnStatus: [],
            positionObj: [],
            dialogHeight: null,
            activeIndex: "1",

            formObjText: formJs.formObjText,
            fSourcefileList: [],
            formData: {},
            tableData: [],
            tableObj: [],
            materialObj: [], //材料集合
            specificationObj: [], //规格型号
            suppliernameObj: [], //生产厂商

            baseFormData: {},

            FauditFileurllist: [], //附件

            btnShow: true,
            currentDetail: null,


            fCompanynames: null,
            fCompanyids: null,
            modelTypes: null,
            engineeringLocationRow: {},
            engineeringLocationShow: false,

            personShow: false,
            selectArr: []

        };
    },
    components: {
        publicForm,
        TableData

    },
    watch: {
        dialogVisible: {
            handler(newVal) {
                if (newVal) {
                    this.visible = newVal;
                }
            },
            immediate: true,
        },
        dialogTitle: {
            handler(newVal) {
                if (newVal) {
                    this.title = newVal;
                }
            },
            immediate: true,
        },
        modelType: {
            handler(newVal) {
                if (newVal) {
                    this.modelTypes = newVal;
                }
            },
            immediate: true,
        },
        statusNum: {
            handler(newVal) {
                if (newVal) {


                    this.edit(newVal);
                }

            },
            immediate: true,
        },

        currentRow: {
            handler(newVal) {
                if (newVal) {
                    this.currentDetail = newVal;
                    console.log(56556);
                    // fStatus
                    this.getExamine(newVal)
                    if (this.statusNum != 1) {
                        this.checkStatus = newVal.F_CheckStatus; //闭合状态
                        this.getDetail({
                            machineId: this.currentDetail.F_MachineId,
                            fId: this.currentDetail.F_Id
                        }) // currentRow
                    }
                }
            },

            immediate: true,
        },
        fCompanyid: {
            handler(newVal) {
                if (newVal) {

                    this.fCompanyids = newVal

                }
            },
            immediate: true,
        },
        fCompanyname: {
            handler(newVal) {
                if (newVal) {
                    this.fCompanynames = newVal

                }
            },
            immediate: true,
        },

    },
    created() {
        window.addEventListener("resize", this.getHeight);
        this.getHeight();
    }, //获取页面高度自适应：

    destroyed() {
        window.removeEventListener("resize", this.getHeight);
        this.getHeight();
    },

    mounted() {
        this.userInfo = JSON.parse(sessionStorage.getItem("yjSmart-userInfo"));

        this.btnShow = true

        
        if (this.statusNum == 7) { //查看
            this.btnShow = false
            this.disabled = true;
           
            this.isEdit = true
           
        }
        this.getHeight();
    },
    methods: {
        // 选择工程部位
        refreshList() {},
        engineeringLocationDialog() {
            this.engineeringLocationShow = false;
        },
        getEngineeringLocation(data) { //获取材料信息
            this.formData.fEnginerringpart = data.F_TreeName; // 报验工程部位
        },
        // 选择工程部位
        // 选择人
        personDialog() {
            this.personShow = false;
        },
        getperson(data) { //单选

            this.selectArr = data;
            this.formData.fAppointstationtesterid = data.fUserid;
            this.formData.fAppointstationtestername = data.fRealname;
        },
        // 选择人
        // 折叠面板
        changeCollapse(e) {
            console.log(this.activeNames, e);
        },
        getHeight() {
            var h = document.documentElement.clientHeight; //获取页面可见高度
            this.dialogHeight = h * 0.76 + "px";
        },
        handleSelect(key) {
            this.activeIndex = key;
        },
        closeDialog() {
            this.$emit("close");
        },


        clickDialog(index, prop) {
            console.log(index, prop);
            if (index == 5 && prop == "fEnginerringpart") {
                this.engineeringLocationShow = true;
                // this.getDataList();
            } else if (index == 2 && prop == "fAppointstationtestername") {
                this.personShow = true;

                // this.formData.fAppointstationtesterid = this.newData.fUserid;
                // this.formData.fAppointstationtestername = this.newData.fRealname;
                //   this.candidate = "选择驻拌合站试验人";

                //   this.getBaseCompanyList();
            }
        },
        edit() {
            this.closeFormData = this.$options.data.call(this).closeFormData;
        },
        // 刪除文件
        delteFile(file) {
            for (let index = 0; index < this.fileList.length; index++) {
                if (file.uid == this.fileList[index].uid) {
                    if (this.fileList[index].atta == undefined) {
                        this.formData.recordfiles.push({
                            fId: this.fileList[index].fId,
                        });
                    } else {
                        this.formData.recordfiles.push({
                            fId: this.fileList[index].atta.fId,
                        });
                    }
                    this.fileList.splice(index, 1);
                }
            }
        },

        getExamine(data) {
            var status = data.F_CheckStatus;
            this.status = data.F_CheckStatus;
            this.handleData.aduitStatus = data.F_CheckStatus; //闭合状态
            this.handleData.fParentid = data.F_Id; //对应的超标记录fid
            getStationWarnByCompanyId({
                    companyId: data.F_CompanyId
                })
                .then((res) => {
                    if (res.errcode == 0) {
                        var row = res.data.yjQmpMsStationwarn;

                        let AduitUserArr = [];
                        let AduitUserData = "";
                        if (data.F_WarningLevel == "1") {
                            AduitUserArr = row.fAduitUser1.split("-");
                        } else if (data.F_WarningLevel == "2") {
                            AduitUserArr = row.fAduitUser2.split("-");
                        } else if (data.F_WarningLevel == "3") {
                            AduitUserArr = row.fAduitUser3.split("-");
                        } else if (data.F_WarningLevel == "4") {
                            AduitUserArr = row.fAduitUser4.split("-");
                        } else if (data.F_WarningLevel == "5") {
                            AduitUserArr = row.fAduitUser5.split("-");
                        }
                        AduitUserData = AduitUserArr[status];
                        console.log(this.userInfo.companyNature, AduitUserData, status, data.F_CloseOperation);
                        this.userInfo = JSON.parse(sessionStorage.getItem("yjSmart-userInfo"));
                        this.btnShow = true;
                        if ((this.userInfo.companyNature == AduitUserData) && data.F_CloseOperation == "未闭合") {
                            if (status == 0) {
                                // 闭合申请单 可编辑
                                this.handNum = true; //闭合申请单
                                this.firstNum = false; //一级审核
                                this.secondNum = false; //二级审核
                                this.threeLevel = false; //三级审核显示
                                this.fourLevel = false; //四级审核显示
                                this.activeNames = ["0"];
                                if (this.handleObj.fHandledates == null || this.handleObj.fHandledates == "") {
                                    this.handleObj.fHandledates = this.common.day(0);
                                    this.handleObj.fHandleusername = this.userInfo.realName; //处理人
                                }
                                // 闭合申请单
                                this.handleObj.map((item) => {
                                    item.disabled = false;
                                });
                                this.handleObj[0].disabled = true;
                                this.handleObj[6].uploadSelect = true

                                // 闭合申请单
                                // 一级审核
                                this.processObj.map((item) => {
                                    item.disabled = true;
                                });
                                // 一级审核
                                //  二级闭合
                                this.examineObj.map((item) => {
                                    item.disabled = true;
                                });
                                //  二级闭合

                                this.processObj[4].uploadSelect = false
                                this.examineObj[4].uploadSelect = false
                            } else if (status == 1) {
                                // 一级审核
                                this.handNum = true; //闭合申请单
                                this.firstNum = true; //一级审核
                                this.secondNum = false; //二级审核
                                this.threeLevel = false; //三级审核显示
                                this.fourLevel = false; //四级审核显示
                                this.activeNames = ["0", "1"];

                                // 闭合申请单
                                this.handleObj.map((item) => {
                                    item.disabled = true;
                                });
                                // 闭合申请单

                                // 一级审核
                                this.processObj.map((item) => {
                                    item.disabled = false;
                                });
                         
                                if (this.closeFormData.fFirstcheckdates == null || this.closeFormData.fFirstcheckdates == "") {
                                    this.closeFormData.fFirstcheckdates = this.common.day(0)
                                    this.closeFormData.fFirstcheckusername = this.userInfo.realName; //一级审核人姓名
                                }
                                // 一级审核


                                //  二级闭合
                                this.examineObj.map((item) => {
                                    item.disabled = true;
                                });
                                //  二级闭合
                                this.handleObj[6].uploadSelect = false
                                // this.processObj[4].uploadSelect = true
                                // this.examineObj[4].uploadSelect = false

                            } else if (status == 2) {
                                //    二级审核
                                this.handNum = true; //闭合申请单
                                this.firstNum = true; //一级审核
                                this.secondNum = true; //二级审核
                                this.activeNames = ["0", "1", "2"];

                                // 闭合
                                this.handleObj.map((item) => {
                                    item.disabled = true;
                                });
                                // 闭合
                                // 一级审核
                                this.processObj.map((item) => {
                                    item.disabled = true;
                                });

                                // 一级审核
                                //  二级闭合
                                this.examineObj.map((item) => {
                                    item.disabled = false;
                                });
                                // this.examineObj[2].disabled = true;
                                // this.examineObj[3].disabled = true;
                                if (this.closeFormData.fSecondcheckdates == null || this.closeFormData.fSecondcheckdates == "") {
                                    this.closeFormData.fSecondcheckdates = this.common.day(0)
                                    this.closeFormData.fSecondcheckusername = this.userInfo.realName; //一级审核人姓名
                                }
                                //  二级闭合
                                this.handleObj[6].uploadSelect = false
                                // this.processObj[4].uploadSelect = false
                                // this.examineObj[4].uploadSelect = true
                            } else if (status == 3) {
                             
                                this.activeNames = ["0", "1", "2","3"];
                                this.handNum = true; //闭合申请单
                                this.firstNum = true; //一级审核
                                this.secondNum = true; //二级审核
                                this.threeLevel = true; //三级审核显示
                                this.fourLevel = false; //四级审核显示
                                // 闭合
                                this.handleObj.map((item) => {
                                    item.disabled = true;
                                });
                                // 闭合
                                // 一级审核
                                this.processObj.map((item) => {
                                    item.disabled = true;
                                });
                                // 一级审核
                                //  二级闭合
                                this.examineObj.map((item) => {
                                    item.disabled = true;
                                });

                                this.handleObj[6].uploadSelect = false

                                 // 三级
                                 this.levelThree.map((item) => {
                                    item.disabled = false;
                                });
                                // 三级
                              
                                //  二级闭合
                            }else if (status == 4) {
                             
                                this.activeNames = ["0", "1", "2","3","4"];
                                this.handNum = true; //闭合申请单
                                this.firstNum = true; //一级审核
                                this.secondNum = true; //二级审核
                                this.threeLevel = true; //三级审核显示
                                this.fourLevel = true; //四级审核显示
                                // 闭合
                                this.handleObj.map((item) => {
                                    item.disabled = true;
                                });
                                // 闭合
                                // 一级审核
                                this.processObj.map((item) => {
                                    item.disabled = true;
                                });
                                // 一级审核
                                //  二级闭合
                                this.examineObj.map((item) => {
                                    item.disabled = true;
                                });
                                this.handleObj[6].uploadSelect = false
                                //  二级闭合
                                  // 三级
                                  this.levelThree.map((item) => {
                                    item.disabled = true;
                                });
                                // 三级
                                // 四级
                                this.levelFourth.map((item) => {
                                    item.disabled = false;
                                });
                            }
                        } else {
                            this.btnShow = false
console.log('status',status);

                            if (status == 0) {
                                this.handNum = true; //闭合申请单
                                this.firstNum = false; //一级审核
                                this.secondNum = false; //二级审核
                                this.threeLevel = false; //三级审核显示
                                this.fourLevel = false; //四级审核显示
                                // 闭合
                                this.handleObj.map((item) => {
                                    item.disabled = true;
                                });
                                this.handleObj[6].uploadSelect = false
                                // 闭合


                            } else if (status == 1) {
                                this.activeNames = ["0"];
                                this.handNum = true; //闭合申请单
                                this.firstNum = false; //一级审核
                                this.secondNum = false; //二级审核
                                this.threeLevel = false; //三级审核显示
                                this.fourLevel = false; //四级审核显示
                                // 闭合
                                this.handleObj.map((item) => {
                                    item.disabled = true;
                                });
                                this.handleObj[6].uploadSelect = false
                                // 闭合

                            } else if (status == 2) {
                                this.activeNames = ["0", "1"]
                                this.handNum = true; //闭合申请单
                                this.firstNum = true; //一级审核
                                this.secondNum = false; //二级审核
                                this.threeLevel = false; //三级审核显示
                                this.fourLevel = false; //四级审核显示
                                // 闭合
                                this.handleObj.map((item) => {
                                    item.disabled = true;
                                });
                                this.handleObj[6].uploadSelect = false
                                // 闭合
                                // 一级审核
                                this.processObj.map((item) => {
                                    item.disabled = true;
                                });
                                // 一级审核

                            } else if (status == 3) {
                                this.activeNames = ["0", "1", "2"]
                                this.handNum = true; //闭合申请单
                                this.firstNum = true; //一级审核
                                this.secondNum = true; //二级审核
                                this.threeLevel = false; //三级审核显示
                                this.fourLevel = false; //四级审核显示
                                // 闭合
                                this.handleObj.map((item) => {
                                    item.disabled = true;
                                });
                                this.handleObj[6].uploadSelect = false
                                // 闭合
                                // 一级审核
                                this.processObj.map((item) => {
                                    item.disabled = true;
                                });
                                // 一级审核
                                //  二级闭合
                                this.examineObj.map((item) => {
                                    item.disabled = true;
                                });
                                //  二级闭合

                            } else if (status == 4) {
                                this.activeNames = ["0", "1", "2", "3"]
                                this.handNum = true; //闭合申请单
                                this.firstNum = true; //一级审核
                                this.secondNum = true; //二级审核
                                this.threeLevel = true; //三级审核显示
                                this.fourLevel = false; //四级审核显示
                                // 闭合
                                this.handleObj.map((item) => {
                                    item.disabled = true;
                                });
                                this.handleObj[6].uploadSelect = false
                                // 闭合
                                // 一级审核
                                this.processObj.map((item) => {
                                    item.disabled = true;
                                });
                                // 一级审核
                                //  二级闭合
                                this.examineObj.map((item) => {
                                    item.disabled = true;
                                });

                                //  二级闭合
                                // 三级
                                this.levelThree.map((item) => {
                                    item.disabled = true;
                                });
                                // 三级



                            } else if (status == 5) {
                                this.activeNames = ["0", "1", "2", "3", "4"]
                                this.handNum = true; //闭合申请单
                                this.firstNum = true; //一级审核
                                this.secondNum = true; //二级审核
                                this.threeLevel = true; //三级审核显示
                                this.fourLevel = true; //四级审核显示
                                // 闭合
                                this.handleObj.map((item) => {
                                    item.disabled = true;
                                });
                                this.handleObj[6].uploadSelect = false
                                // 闭合
                                // 一级审核
                                this.processObj.map((item) => {
                                    item.disabled = true;
                                });
                                // 一级审核
                                //  二级闭合
                                this.examineObj.map((item) => {
                                    item.disabled = true;
                                });

                                //  二级闭合
                                // 三级
                                this.levelThree.map((item) => {
                                    item.disabled = true;
                                });
                                // 三级
                                // 四级
                                this.levelFourth.map((item) => {
                                    item.disabled = true;
                                });
                                // 四级

                            }
                        }
                    }
                })
                .catch((error) => {
                    console.log(error);
                });
        },


        // 详情
        getDetail(obj) {

            getStationmachineByfMachineid({
                    machineId: obj.machineId
                })
                .then((res1) => {
                    if (res1.errcode == 0) {
                        this.material_config.thead[4].label =
                            res1.data.yjQmpMsStationmachine.fParm1;
                        this.material_config.thead[5].label =
                            res1.data.yjQmpMsStationmachine.fParm2;
                        this.material_config.thead[6].label =
                            res1.data.yjQmpMsStationmachine.fParm3;
                        this.material_config.thead[7].label =
                            res1.data.yjQmpMsStationmachine.fParm4;
                        this.material_config.thead[8].label =
                            res1.data.yjQmpMsStationmachine.fParm5;
                        var str;
                        if (this.isclose) {
                            str = getClosedFormByParentId
                        } else {
                            str = getMixInfoById
                        }

                        str({
                            fId: obj.fId,
                            fCompanyid: this.fCompanyids,
                        }).then((res) => {
                            if (res.errcode == 0) {
                                console.log(res.data);
                                var that = this;
                                that.loadingEditDialog = false;
                                that.dialogEditVisible = true;
                                that.formData = res.data.dischargeinfo;
                                console.log(this.checkStatus, 999999, this.isclose);
                                var totalData = res.data.closeinfo; //闭合申请单、一级、二级、三级、四级审核
                                if (this.isclose) {
                                    console.log('99999966666');
                                    if (this.checkStatus == 0) {
                                        this.handleData.fId = totalData.fId; //申请单fid //为空判断为新增
                                        this.handleData.fWarningcontent = totalData.fWarningcontent; // 预警内容
                                        this.handleData.fHandlefile = totalData.fHandlefile; //处理附件id
                                        this.handleData.fCompanyid = that.formData.fCompanyid; // 施工标段id
                                    } else if (this.checkStatus == 1) {
                                        this.handleData.fId = totalData.fId; //申请单fid //为空判断为新增
                                        this.handleData.fCompanyid = totalData.fCompanyid; // 施工标段id
                                        this.handleData.fWarningcontent = totalData.fWarningcontent; // 预警内容
                                        this.handleData.fHandlefile = totalData.fHandlefile; //处理附件id

                                        this.handleData.fReason = totalData.fReason; // 问题原因
                                        this.handleData.fHandleresult = totalData.fHandleresult; // 处理结果
                                        this.handleData.fHandledates = totalData.fHandledates; //处理日期
                                        this.handleData.fHandleusername = totalData.fHandleusername; // 处理人名称
                                        this.fSourcefileList = res.data.fSourcefileList; // 附件
                                        this.handleData.fHandleway = totalData.fHandleway; // 处理方式
                                    } else if (this.checkStatus == 2) {
                                        this.handleData.fId = totalData.fId; //申请单fid //为空判断为新增
                                        this.handleData.fCompanyid = totalData.fCompanyid; // 施工标段id
                                        this.handleData.fWarningcontent = totalData.fWarningcontent; // 预警内容
                                        this.handleData.fHandlefile = totalData.fHandlefile; //处理附件id

                                        this.handleData.fReason = totalData.fReason; // 问题原因
                                        this.handleData.fHandleresult = totalData.fHandleresult; // 处理结果
                                        this.handleData.fHandledates = totalData.fHandledates; //处理日期
                                        this.handleData.fHandleusername = totalData.fHandleusername; // 处理人名称
                                        this.fSourcefileList = res.data.fSourcefileList; // 附件
                                        this.handleData.fHandleway = totalData.fHandleway; // 处理方式
                                        this.handleData.fFirstcheckresult =
                                            totalData.fFirstcheckresult; // 一级审核处理结果
                                        this.handleData.fFirstcheckopinion =
                                            totalData.fFirstcheckopinion; // 一级审核处理意见
                                        this.handleData.fFirstcheckusername =
                                            totalData.fFirstcheckusername; //一级审核处理人name
                                        this.handleData.fFirstcheckdates =
                                            totalData.fFirstcheckdates; //一级审核处理日期
                                    } else if (this.checkStatus == 3) {
                                        this.handleData.fId = totalData.fId; //申请单fid //为空判断为新增
                                        this.handleData.fCompanyid = totalData.fCompanyid; // 施工标段id
                                        this.handleData.fWarningcontent = totalData.fWarningcontent; // 预警内容
                                        this.handleData.fReason = totalData.fReason; // 问题原因

                                        this.handleData.fHandleresult = totalData.fHandleresult; // 处理结果
                                        this.handleData.fHandledates = totalData.fHandledates; //处理日期
                                        this.handleData.fHandleusername = totalData.fHandleusername; // 处理人名称
                                        this.fSourcefileList = res.data.fSourcefileList; // 附件
                                        this.handleData.fHandlefile = totalData.fHandlefile; //处理附件id
                                        this.handleData.fHandleway = totalData.fHandleway; // 处理方式

                                        this.handleData.fFirstcheckresult =
                                            totalData.fFirstcheckresult; // 一级审核处理结果
                                        this.handleData.fFirstcheckopinion =
                                            totalData.fFirstcheckopinion; // 一级审核处理意见
                                        this.handleData.fFirstcheckusername =
                                            totalData.fFirstcheckusername; //一级审核处理人name
                                        this.handleData.fFirstcheckdates =
                                            totalData.fFirstcheckdates; //一级审核处理日期

                                        this.handleData.fSecondcheckresult =
                                            totalData.fSecondcheckresult; // 二级审核处理结果
                                        this.handleData.fSecondcheckopinion =
                                            totalData.fSecondcheckopinion; // 二级审核处理意见
                                        this.handleData.fSecondcheckusername =
                                            totalData.fSecondcheckusername; //二级审核处理人name
                                        this.handleData.fSecondcheckdates =
                                            totalData.fSecondcheckdates; //二级审核处理日期
                                    } else if (this.checkStatus == 4) {
                                        this.handleData.fId = totalData.fId; //申请单fid //为空判断为新增
                                        this.handleData.fCompanyid = totalData.fCompanyid; // 施工标段id
                                        this.handleData.fWarningcontent = totalData.fWarningcontent; // 预警内容
                                        this.handleData.fReason = totalData.fReason; // 问题原因

                                        this.handleData.fHandleresult = totalData.fHandleresult; // 处理结果
                                        this.handleData.fHandledates = totalData.fHandledates; //处理日期
                                        this.handleData.fHandleusername = totalData.fHandleusername; // 处理人名称
                                        this.fSourcefileList = res.data.fSourcefileList; // 附件
                                        this.handleData.fHandlefile = totalData.fHandlefile; //处理附件id
                                        this.handleData.fHandleway = totalData.fHandleway; // 处理方式

                                        this.handleData.fFirstcheckresult =
                                            totalData.fFirstcheckresult; // 一级审核处理结果
                                        this.handleData.fFirstcheckopinion =
                                            totalData.fFirstcheckopinion; // 一级审核处理意见
                                        this.handleData.fFirstcheckusername =
                                            totalData.fFirstcheckusername; //一级审核处理人name
                                        this.handleData.fFirstcheckdates =
                                            totalData.fFirstcheckdates; //一级审核处理日期

                                        this.handleData.fSecondcheckresult =
                                            totalData.fSecondcheckresult; // 二级审核处理结果
                                        this.handleData.fSecondcheckopinion =
                                            totalData.fSecondcheckopinion; // 二级审核处理意见
                                        this.handleData.fSecondcheckusername =
                                            totalData.fSecondcheckusername; //二级审核处理人name
                                        this.handleData.fSecondcheckdates =
                                            totalData.fSecondcheckdates; //二级审核处理日期

                                        this.handleData.fThirdcheckresult =
                                            totalData.fThirdcheckresult; // 三级审核处理结果
                                        this.handleData.fThirdcheckopinion =
                                            totalData.fThirdcheckopinion; // 三级审核处理意见
                                        this.handleData.fThirdcheckusername =
                                            totalData.fThirdcheckusername; //三级审核处理人name
                                        this.handleData.fThirdcheckdates =
                                            totalData.fThirdcheckdates; //三级审核处理日期
                                    } else if (this.checkStatus == 5) {
                                        this.handleData.fId = totalData.fId; //申请单fid //为空判断为新增
                                        this.handleData.fCompanyid = totalData.fCompanyid; // 施工标段id
                                        this.handleData.fWarningcontent = totalData.fWarningcontent; // 预警内容
                                        this.handleData.fReason = totalData.fReason; // 问题原因

                                        this.handleData.fHandleresult = totalData.fHandleresult; // 处理结果
                                        this.handleData.fHandledates = totalData.fHandledates; //处理日期
                                        this.handleData.fHandleusername = totalData.fHandleusername; // 处理人名称
                                        this.fSourcefileList = res.data.fSourcefileList; // 附件
                                        this.handleData.fHandlefile = totalData.fHandlefile; //处理附件id
                                        this.handleData.fHandleway = totalData.fHandleway; // 处理方式

                                        this.handleData.fFirstcheckresult =
                                            totalData.fFirstcheckresult; // 一级审核处理结果
                                        this.handleData.fFirstcheckopinion =
                                            totalData.fFirstcheckopinion; // 一级审核处理意见
                                        this.handleData.fFirstcheckusername =
                                            totalData.fFirstcheckusername; //一级审核处理人name
                                        this.handleData.fFirstcheckdates =
                                            totalData.fFirstcheckdates; //一级审核处理日期

                                        this.handleData.fSecondcheckresult =
                                            totalData.fSecondcheckresult; // 二级审核处理结果
                                        this.handleData.fSecondcheckopinion =
                                            totalData.fSecondcheckopinion; // 二级审核处理意见
                                        this.handleData.fSecondcheckusername =
                                            totalData.fSecondcheckusername; //二级审核处理人name
                                        this.handleData.fSecondcheckdates =
                                            totalData.fSecondcheckdates; //二级审核处理日期

                                        this.handleData.fThirdcheckresult =
                                            totalData.fThirdcheckresult; // 三级审核处理结果
                                        this.handleData.fThirdcheckopinion =
                                            totalData.fThirdcheckopinion; // 三级审核处理意见
                                        this.handleData.fThirdcheckusername =
                                            totalData.fThirdcheckusername; //三级审核处理人name
                                        this.handleData.fThirdcheckdates =
                                            totalData.fThirdcheckdates; //二级审核处理日期

                                        this.handleData.fFourthcheckresult =
                                            totalData.fFourthcheckresult; // 四级审核处理结果
                                        this.handleData.fFourthcheckopinion =
                                            totalData.fFourthcheckopinion; // 四级审核处理意见
                                        this.handleData.fFourthcheckusername =
                                            totalData.fFourthcheckusername; //四级审核处理人name
                                        this.handleData.fFourthcheckdates =
                                            totalData.fFourthcheckdates; //四级审核处理日期
                                    }
                                }
                                this.materialData = [{
                                        // fCement2deviatevalue
                                        name: "设计重量值(kg)",
                                        water: res.data.dischargeinfo.fWaterdesignvalue,
                                        cement1: res.data.dischargeinfo.fCement1designvalue,
                                        cement2: res.data.dischargeinfo.fCement2designvalue,
                                        aggregate1: res.data.dischargeinfo.fAggregate1designvalue,
                                        aggregate2: res.data.dischargeinfo.fAggregate2designvalue,
                                        aggregate3: res.data.dischargeinfo.fAggregate3designvalue,
                                        aggregate4: res.data.dischargeinfo.fAggregate4designvalue,
                                        aggregate5: res.data.dischargeinfo.fAggregate5designvalue,
                                        oredesign: res.data.dischargeinfo.fOredesignvalue,
                                        flyash: res.data.dischargeinfo.fFlyashdesignvalue,
                                        admixture1: res.data.dischargeinfo.fAdmixture1designvalue,
                                        admixture2: res.data.dischargeinfo.fAdmixture2designvalue,
                                        // cement3: "",
                                    },
                                    {
                                        name: "实际称量值(kg)",
                                        water: res.data.dischargeinfo.fWateractualvalue,
                                        cement1: res.data.dischargeinfo.fCement1actualvalue,
                                        cement2: res.data.dischargeinfo.fCement2actualvalue,
                                        // cement3: "",
                                        aggregate1: res.data.dischargeinfo.fAggregate1actualvalue,
                                        aggregate2: res.data.dischargeinfo.fAggregate2actualvalue,
                                        aggregate3: res.data.dischargeinfo.fAggregate3actualvalue,
                                        aggregate4: res.data.dischargeinfo.fAggregate4actualvalue,
                                        aggregate5: res.data.dischargeinfo.fAggregate5actualvalue,
                                        oredesign: res.data.dischargeinfo.fOreactualvalue,
                                        flyash: res.data.dischargeinfo.fFlyashactualvalue,
                                        admixture1: res.data.dischargeinfo.fAdmixture1actualvalue,
                                        admixture2: res.data.dischargeinfo.fAdmixture2actualvalue,
                                    },
                                    {
                                        name: "重量偏差(%)",
                                        water: res.data.dischargeinfo.fWaterdeviatevalue, //水
                                        cement1: res.data.dischargeinfo.fCement1deviatevalue, //水泥1
                                        cement2: res.data.dischargeinfo.fCement2deviatevalue, //水泥2
                                        aggregate1: res.data.dischargeinfo.fAggregate1deviatevalue, //骨料1
                                        aggregate2: res.data.dischargeinfo.fAggregate2deviatevalue, //骨料2
                                        aggregate3: res.data.dischargeinfo.fAggregate3deviatevalue, //骨料3
                                        aggregate4: res.data.dischargeinfo.fAggregate4deviatevalue, //骨料4
                                        aggregate5: res.data.dischargeinfo.fAggregate5deviatevalue, //骨料5
                                        oredesign: res.data.dischargeinfo.fOredeviatevalue, //矿粉
                                        flyash: res.data.dischargeinfo.fFlyashdeviatevalue, //粉煤灰
                                        admixture1: res.data.dischargeinfo.fAdmixture1deviatevalue, //外加剂1
                                        admixture2: res.data.dischargeinfo.fAdmixture2deviatevalue, //外加剂2
                                    },
                                    {
                                        name: "",
                                        show: true,
                                        water: res.data.dischargeinfo.fWaterwarninginfo, //水
                                        cement1: res.data.dischargeinfo.fCement1warninginfo, //水泥1
                                        cement2: res.data.dischargeinfo.fCement2warninginfo, //水泥2
                                        aggregate1: res.data.dischargeinfo.fAggregate1warninginfo, //骨料1
                                        aggregate2: res.data.dischargeinfo.fAggregate2warninginfo, //骨料2
                                        aggregate3: res.data.dischargeinfo.fAggregate3warninginfo, //骨料3
                                        aggregate4: res.data.dischargeinfo.fAggregate4warninginfo, //骨料4
                                        aggregate5: res.data.dischargeinfo.fAggregate5warninginfo, //骨料5
                                        oredesign: res.data.dischargeinfo.fOrewarninginfo, //矿粉
                                        flyash: res.data.dischargeinfo.fFlyashwarninginfo, //粉煤灰
                                        admixture1: res.data.dischargeinfo.fAdmixture1warninginfo, //外加剂1
                                        admixture2: res.data.dischargeinfo.fAdmixture2warninginfo, //外加剂2
                                    },
                                ];
                                this.level = [
                                    "",
                                    res.data.dischargeinfo.fWaterwarninglevel,
                                    res.data.dischargeinfo.fCement1warninglevel,
                                    res.data.dischargeinfo.fCement2warninglevel,
                                    res.data.dischargeinfo.fAggregate1warninglevel,
                                    res.data.dischargeinfo.fAggregate2warninglevel,
                                    res.data.dischargeinfo.fAggregate3warninglevel,
                                    res.data.dischargeinfo.fAggregate4warninglevel,
                                    res.data.dischargeinfo.fAggregate5warninglevel,
                                    res.data.dischargeinfo.fOrewarninglevel,
                                    res.data.dischargeinfo.fFlyashwarninglevel,
                                    res.data.dischargeinfo.fAdmixture1warninglevel,
                                    res.data.dischargeinfo.fAdmixture2warninglevel,
                                ];
                                this.earlyWarning = [
                                    "",
                                    res.data.dischargeinfo.fWaterwarninginfo,
                                    res.data.dischargeinfo.fCement1warninginfo,
                                    res.data.dischargeinfo.fCement2warninginfo,
                                    res.data.dischargeinfo.fAggregate1warninginfo,
                                    res.data.dischargeinfo.fAggregate2warninginfo,
                                    res.data.dischargeinfo.fAggregate3warninginfo,
                                    res.data.dischargeinfo.fAggregate4warninginfo,
                                    res.data.dischargeinfo.fAggregate5warninginfo,
                                    res.data.dischargeinfo.fOrewarninginfo,
                                    res.data.dischargeinfo.fFlyashwarninginfo,
                                    res.data.dischargeinfo.fAdmixture1warninginfo,
                                    res.data.dischargeinfo.fAdmixture2warninginfo,
                                ];

                                var Cement1 = null; //水泥1
                                if (
                                    res.data.dischargeinfo.fCement1actualvalue != null &&
                                    res.data.dischargeinfo.fCement1actualvalue != null
                                ) {
                                    Cement1 = res.data.dischargeinfo.fCement1actualvalue - 0;
                                } else {
                                    Cement1 = 0;
                                }
                                var Cement2 = null; //水泥2
                                if (
                                    res.data.dischargeinfo.fCement2actualvalue != null &&
                                    res.data.dischargeinfo.fCement2actualvalue != null
                                ) {
                                    Cement2 = res.data.dischargeinfo.fCement2actualvalue - 0;
                                } else {
                                    Cement2 = 0;
                                }
                                var Oreactual = null; //矿粉
                                if (
                                    res.data.dischargeinfo.fOreactualvalue != null &&
                                    res.data.dischargeinfo.fOreactualvalue != null
                                ) {
                                    Oreactual = res.data.dischargeinfo.fOreactualvalue - 0;
                                } else {
                                    Oreactual = 0;
                                }
                                var Flyashactual = null; //粉煤灰
                                if (
                                    res.data.dischargeinfo.fFlyashactualvalue != null &&
                                    res.data.dischargeinfo.fFlyashactualvalue != null
                                ) {
                                    Flyashactual =
                                        res.data.dischargeinfo.fFlyashactualvalue - 0;
                                } else {
                                    Flyashactual = 0;
                                }
                                var Admixture1 = null; //外加剂1
                                if (
                                    res.data.dischargeinfo.fAdmixture1actualvalue != null &&
                                    res.data.dischargeinfo.fAdmixture1actualvalue != null
                                ) {
                                    Admixture1 =
                                        res.data.dischargeinfo.fAdmixture1actualvalue - 0;
                                } else {
                                    Admixture1 = 0;
                                }
                                var Admixture2 = null; //外加剂2
                                if (
                                    res.data.dischargeinfo.fAdmixture2actualvalue != null &&
                                    res.data.dischargeinfo.fAdmixture2actualvalue != null
                                ) {
                                    Admixture2 =
                                        res.data.dischargeinfo.fAdmixture2actualvalue - 0;
                                } else {
                                    Admixture2 = 0;
                                }
                                // 水胶比=水/胶凝材料（水泥+矿粉+粉煤灰）
                                var fWaterbinderratio =
                                    res.data.dischargeinfo.fWateractualvalue /
                                    (Cement1 + Cement2 + Oreactual + Flyashactual);
                                this.formData.fWaterbinderratio =
                                    Math.floor(fWaterbinderratio * 100) / 100;

                                // 外加剂掺量=外加剂/胶凝材料（水泥+矿粉+粉煤灰）*100
                                var fAdditiveratio =
                                    ((Admixture1 + Admixture2) /
                                        (Cement1 + Cement2 + Oreactual + Flyashactual)) *
                                    100;
                                this.formData.fAdditiveratio =
                                    Math.floor(fAdditiveratio * 100) / 100;
                            } else {
                                this.$message.error(res.msg);
                            }
                        });
                    } else {
                        this.$message.error(res1.msg);
                        console.log("接口报错");
                    }
                })
                .catch((error) => {
                    console.log("拌合站设置编辑报错", error);
                });

        },
        yj_saveForm() {
            this.handleData.userId = this.userInfo.userId; // //编制人id
            this.handleData.userName = this.userInfo.realName; // //编制人
            var text = 'publicForm' + this.status
            console.log(this.$refs[text], this.handleData);
            if (this.$refs[text].submitForm()) {
                this.saveForm(this.handleData, 0);
            }
            // if (this.status == 0) {
            //     if(this.$refs.publicForm0.submitForm()){
            //         this.saveForm(this.formData, 0);
            //     }

            // } else if (this.status == 1) {
            //     if(this.$refs.publicForm1.submitForm() ){
            //         this.saveForm(this.formData, 1);
            //     }


            // } else if (this.status == 2) {

            //     if(this.$refs.publicForm2.submitForm()  ){
            //         this.saveForm(this.formData, 0);
            //     }
            // }else if (this.status == 3) {

            //     if(this.$refs.publicForm3.submitForm()  ){
            //         this.saveForm(this.formData, 0);
            //     }
            // } else if (this.status == 4) {

            //     if(this.$refs.publicForm4.submitForm()  ){
            //         this.saveForm(this.formData, 0);
            //     }
            // }else {
            //     console.log("error");
            // }

        },
        // 保存
        saveForm(obj) {
            console.log(obj);
            this.isLock = true
            addClosedForm(obj)
                .then((res) => {
                    if (res.errcode == 0) {
                        this.visible = false;
                        this.$emit("refreshList");
                        this.$message.success("新增成功");
                        this.isLock = false
                    } else {
                        this.isLock = false
                        this.$message.error(res.msg);
                        console.log("接口报错");
                    }
                })
                .catch((error) => {
                    console.log("拌合站设置-新增）", error);
                });
        },
    },
};